package com.example.smartclassroom.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.smartclassroom.entity.Room;
import com.example.smartclassroom.mapper.RoomMapper;
import com.example.smartclassroom.service.RoomServie;
import com.example.smartclassroom.util.JsonDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomServie {
    @Autowired
    private RoomMapper roomMapper;
    /**
     * 根据id查询教室信息
     */
    public JsonDate queryRoomById(Integer id) {
        JsonDate date = new JsonDate();
        if (roomMapper.queryRoomById(id) == null) {
            date.setMsg("教室不存在");
            return date;
        }else {
            date.setData(roomMapper.queryRoomById(id));
            date.setMsg("查询成功");
            return date;
        }
    }

    /**
     * 查询所有教室
     */
    public JsonDate queryAllRoomName() {
        JsonDate date = new JsonDate();
        date.setData(roomMapper.queryAllRoomName());
        return date;
    }
}
